import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'widget/footer.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'custom/custom_localizations.dart';

class G {
  /// 导航唯一key
  static final GlobalKey<NavigatorState> navigatorKey = GlobalKey();
  /// 获取构建上下文
  static BuildContext getCurrentContext() => navigatorKey.currentContext!;

  static Widget footer() {
    return Footer();
  }

  static success(String msg) {
    EasyLoading.showSuccess(msg);
  }

  static error(String msg) {
    EasyLoading.showError(msg);
  }

  static toast(String msg) {
    EasyLoading.showToast(msg);
  }

  static info(String msg) {
    EasyLoading.showInfo(msg);
  }

  static prefs() async {
    return await await SharedPreferences.getInstance();
  }

  /// 路由
  static FluroRouter router = FluroRouter();

  /// 翻译函数
  static String t(String key) {
    return CustomLocalizations.of(getCurrentContext()).t(key);
  }
}